<?php
/**
 * Created by PhpStorm.
 * User: houreshared
 * Date: 2017/9/5
 * Time: 下午6:37
 */

namespace App\Repository;


use Illuminate\Database\Eloquent\Model;

abstract class BaseRepository
{
    protected $modals = [];

    protected function modal($name, Model $modal = null)
    {
        if (is_null($modal)) {
            if (!key_exists($name, $this->modals)) {
                return null;
            }

            return $this->modals[$name];
        }

        if (key_exists($name, $this->modals)) {
            throw new \Exception('repeat modal name');
        }

        $this->modals[$name] = $modal;
    }
}